<include file="Admin@Public/header" /> 
<link rel="stylesheet" href="__PUBLIC__/tageditor/css/tag-editor.css">
<div class="col-sm-10 col-sm-offset-3 col-md-10 col-md-offset-2 main">
    <ol class="breadcrumb">
      <li>网站内容</li>
      <li>文章管理</li>
      <li class="active">添加</li>
    </ol>
    <form  class="form-horizontal" role="form" action="__URL__/save" >
      <input type="hidden" name="inputId" value="0" >
      <input type="hidden" name="inputTypeId" value="{$type.id}"> 
      <div class="form-group">
        <label for="inputTypeName" class="col-sm-1 control-label">栏目 </label>
        <div class="col-sm-7">
            <input type="text" class="form-control"  value="{$type.name}" readonly>
        </div>
      </div>
      <div class="form-group">
        <label for="inputTitle" class="col-sm-1 control-label">标题 </label>
        <div class="col-sm-7">
          <input type="text" class="form-control" id="inputTitle" name="inputTitle" placeholder="请输入文章标题" datatype="*1-80" errormsg="<i class='icon-warning-sign'></i> 标题在1~80位之间"  nullmsg="<i class='icon-warning-sign'></i> 请填写信息！" sucmsg="<i class='icon-ok'></i>">
        </div>
        <div class="Validform_checktip">
           <div class="Validform-info">标题至少1个字符,最多80个字符<span class="dec"><s class="dec1">&#9670;</s><s class="dec2">&#9670;</s></span></div>
        </div>
      </div>
      <div class="form-group">
        <label for="inputKeywords" class="col-sm-1 control-label">关键词 </label>
        <div class="col-sm-7">
          <input type="text" class="form-control" id="inputKeywords" name="inputKeywords" placeholder="请输入文章关键词" datatype="*0-100" errormsg="<i class='icon-warning-sign'></i> 文章关键词在0~100位之间"  nullmsg="<i class='icon-warning-sign'></i> 请填写信息！" sucmsg="<i class='icon-ok'></i>">
        </div>
        <div class="Validform_checktip">
           <div class="Validform-info">文章关键词请以“,”隔开<span class="dec"><s class="dec1">&#9670;</s><s class="dec2">&#9670;</s></span></div>
        </div>
      </div>
      <div class="form-group">
        <label for="inputIntroduction" class="col-sm-1 control-label">描述 </label>
        <div class="col-sm-7">
          <textarea class="form-control" id="inputIntroduction" name="inputIntroduction" placeholder="请输入文章描述" datatype="*0-200" errormsg="<i class='icon-warning-sign'></i> 分类名在0~200位之间"  nullmsg="<i class='icon-warning-sign'></i> 请填写信息！" sucmsg="<i class='icon-ok'></i>"></textarea>
        </div>
        <div class="Validform_checktip">
           <div class="Validform-info">文章描述最多200个字符<span class="dec"><s class="dec1">&#9670;</s><s class="dec2">&#9670;</s></span></div>
        </div>
      </div>
      <div class="form-group">
        <label for="inputUrl" class="col-sm-1 control-label">URL </label>
        <div class="col-sm-7">
          <input type="text" class="form-control" id="inputUrl" name="inputUrl" placeholder="请输入栏目自定义链接" datatype="p_url" errormsg="<i class='icon-warning-sign'></i> 链接含有非法字符或已存在"  ignore="ignore" ajaxurl="/Plugin/verify/validNoUrl?m=article" sucmsg="<i class='icon-ok'></i>">
        </div>
        <div class="Validform_checktip">
           <div class="Validform-info">自定义链接如：news-title-ps<span class="dec"><s class="dec1">&#9670;</s><s class="dec2">&#9670;</s></span></div>
        </div>
      </div>
      <?php $tpl_article = getTplFiles("Article"); ?>
      <div class="form-group">
        <label for="inputTemplate" class="col-sm-1 control-label">模版 </label>
        <div class="col-sm-4">
          <select name="inputTemplate" id="inputTemplate" class="form-control">
            <volist name="tpl_article" id="tpl">
              <option value="{$tpl.name}" <if condition="$type['template']==$tpl['name']">selected="selected"</if> >{$tpl.fullname}</option>
            </volist>  
          </select>
        </div>
      </div>
      <div class="form-group">
        <label for="inputSource" class="col-sm-1 control-label">来源 </label>
        <div class="col-sm-3">
          <input type="text" class="form-control" id="inputSource" name="inputSource" placeholder="请输入文章来源">
        </div>
         <div class="col-sm-4">
          <input type="text" class="form-control" id="inputSource_url" name="inputSource_url" datatype="url" ignore="ignore" placeholder="请输入文章来源链接 https://" errormsg="<i class='icon-warning-sign'></i> web地址无效" sucmsg="<i class='icon-ok'></i>">
        </div>
        <div class="Validform_checktip">
           <div class="Validform-info">文章来源与web地址<span class="dec"><s class="dec1">&#9670;</s><s class="dec2">&#9670;</s></span></div>
        </div>
      </div>
      <div class="form-group">
        <label for="inputContent" class="col-sm-1 control-label">内容 </label>
        <div class="col-sm-7">
          <script id="ueditor" name="inputContent" type="text/plain">
          </script>
        </div>
      </div>
       <div class="form-group">
        <label for="file_upload" class="col-sm-1 control-label">图集 </label>
        <div class="col-sm-3">
          <input type="file" name="file_upload" id="file_upload">
        </div>
        <div class="col-sm-4">
          图片格式为 'jpg','jpeg','gif','png' ，文件大小 小于2M
        </div>
      </div>
      <div class="form-group">
        <label class="col-sm-1 control-label"> </label>
        <div class="col-sm-7">
          <div class="table-responsive table-bd">
             <table class="table">
                <thead>
                  <tr>
                    <th class="col-md-2">排序</th>
                    <th class="col-md-4">图片</th>
                    <th class="col-md-4">名称</th>
                    <th class="col-md-2">操作</th>
                  </tr>
                </thead>
                <tbody id="imageList">
                </tbody>
              </table>
          </div>  
        </div>
      </div>
<?php $attributeList = R('Content/article/getAttributes',array($type['id']));?>
<notempty name="attributeList">   
  <div class="form-group">
    <label for="inputContent" class="col-sm-1 control-label">拓展属性 </label>
    <div class="col-sm-7">
      <div class="attribute-wrap">
      <volist name="attributeList" id="attribute">
          <div class="form-group">
            <label for="inputContent" class="col-sm-2 control-label">{$attribute.attributezh} </label>
            <div class="col-sm-5">
               <input type="hidden"  name="inputArticleAttributeIds[]" value="0">
               <input type="hidden"  name="inputAttributeIds[]" value="{$attribute.id}">
               <input type="hidden"  name="inputMarks[]" value="{$attribute.mark}">
               <input type="text" class="form-control" name="inputAttributeValues[]">
            </div>
          </div>
      </volist>
      </div>
    </div>
  </div>
</notempty>  
      <div class="form-group">
        <label for="inputCreatetime" class="col-sm-1 control-label">发布时间 </label>
        <div class="col-sm-4">
        <?php $nowDatetime=date('Y-m-d H:i:s');?>
          <input type="text" class="Wdate form-control" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',maxDate:'%y-%M-%d'})" id="inputCreatetime" name="inputCreatetime" readonly="readonly" placeholder="请输入文章信息来源" datatype="*" value="{$nowDatetime}" sucmsg="<i class='icon-ok'></i>">
        </div>
      </div>
      <div class="form-group">
      <label for="inputTop" class="col-sm-1 control-label">是否置顶</label>
        <div class="col-sm-3">
          <input type="checkbox" name="inputTop" value="1" id="inputTop" > 置顶
        </div>
      </div>
      <div class="form-group">
        <label for="inputStatus" class="col-sm-1 control-label"> </label>
        <div class="col-sm-4">
          <input type="button" class="btn btn-primary" value="添加" id="btn_sub"/>
           <a href="__URL__/index" class="btn btn-default" >返回</a>
      </div>
    </div>
    </form> 
</div>
<script src="__PUBLIC__/datepicker/WdatePicker.js"></script>
<script src="__PUBLIC__/tageditor/js/caret.min.js"></script>
<script src="__PUBLIC__/tageditor/js/tag-editor.js"></script>
<script type="text/javascript">
    <?php $timestamp = time();?>
    $(function() {
      removeImage();
      $('#file_upload').uploadify({
          'formData'     : {
            'timestamp' : '<?php echo $timestamp;?>',
            'token'     : '<?php echo md5('unique_salt' . $timestamp);?>'
            },
          'buttonText':"选择文件",
          'swf'      : '__PUBLIC__/uploadify/uploadify.swf',
          'uploader' : '/Plugin/Upload/upload/',
          'onUploadSuccess' : function(file, data, response) {
            var data = eval( '(' + data + ')' ); //json：存在json数组和json实体
            if (data.status) {
               var imageListStr = putImageList(data.imageId,data.imageSrc,data.imageAlt);
               $('#imageList').append(imageListStr);
            };
          }
      });
      removeImage();
    });
    function putImageList(imageId,imageSrc,imageAlt){
        var imageSrcRoot='<?php echo (C("IMAGE_ROOTPATH"));?>';
        imageSrc=imageSrcRoot+imageSrc;
        var imageListStr="<tr><td><input type='hidden' name='inputImageids[]' value='"+imageId+"'><input type='hidden' name='inputArticleImageids[]' value='0'><input type='text' size='3' name='inputImageorders[]' value='0' class='input-listorder' /></td><td><img src='"+imageSrc+"' width='146' height='86'></td><td><textarea class='txt-area'  name='inputImagetitles[]'>"+imageAlt+"</textarea></td><td><a href='javascript:removeImage();' class='btn btn-primary btn-xs remove-image'><i class='icon-remove'></i> 移除</a></td></tr>";
        return imageListStr;
    }
   var ue = UE.getEditor('ueditor'); //umedit init
function removeImage(){
    $('.remove-image').each(function(i){
      $(this).click(function(){
         $('#imageList > tr').eq(i).remove();
      });
    });
}
$('#inputKeywords').tagEditor({
    delimiter: ', ', /* space and comma */
    placeholder: '请输入文章关键词 ...',
});

</script>
<include file="Admin@Public/script_form" /> 
<include file="Admin@Public/footer" /> 
   
